//u.js
//获取应用实例
const app = getApp();
var utils = require('../../utils/util.js');
Page({
  data: {
    result: '',
    data: '',
    codes: '',
    userInfo: '',
    hasUserInfo: false,
    activity: '',
    actime: true
  },

  onLoad: function () {
    var that = this;
    wx.request({
      url: 'https://www.cacalife.cn/home/lecaca/huodong',
      methods: 'POST',
      header: { 'content-type': 'application/json' },
      success: function (res) {
        var activity = res.data;
        for (var i = 0; i < activity.length; i++) {
          var end_time = activity[i]['end_time'];
          var formatetime = utils.timestampToTime(end_time);
          activity[i]['end_time'] = formatetime;
          if (activity[i]['state']==2){
            that.setData({
              actime: false
            })
          } else if (activity[i]['state']==1){
            that.setData({
              actime: true
            })
          }
          console.log(activity)
          that.setData({
            activity: activity
          })
        }
        
      }
    })
  }
})
